<?php defined('BASEPATH') or exit('No direct script access allowed');

class Addshow_m extends MY_Model {
	
	function __construct(){
		parent::__construct();
		$this->load->library('module_helper');
	}
	
	function index(){
		$showType = form_dropdown( 'show_type',
										$options = showTypeDataConfig(),
										$selected = array(),
										"id='show_type' class='width270'"
									);
		$durationShow = form_dropdown( 'show_duration',
										$options = durationOfShowDataConfig(),
										$selected = array(),
										"id='show_duration' class='width270'"
									);							
		$countryOrigin = form_dropdown( 'country_origin',
										$options = countryOriginDataConfig(),
										$selected = array(),
										"id='country_origin' class='width270'"
									);		
	/**	$available_for = form_multiselect( 'available_for[]',
										$options = countryZoneDataConfig(),
										$selected = array(),
										"id='available_for[]' class='width270'"
									);	**/
		$air_travel = form_dropdown( 'air_travel',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array(),
										"id='air_travel' class='width270'"
									);	
		$ground = form_dropdown( 'ground',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array(),
										"id='ground' class='width270'"
									);
		$hotel = form_dropdown( 'hotel',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array(),
										"id='hotel' class='width270'"
									);							
		$per_diem = form_dropdown( 'per_diem',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array(),
										"id='per_diem' class='width270'"
									);		
		$light_n_sound = form_dropdown( 'light_n_sound',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array(),
										"id='light_n_sound' class='width270'"
									);	
		$rider_req = form_dropdown( 'rider_req',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array(),
										"id='rider_req' class='width270'"
									);	
		$visa_n_work_permits = form_dropdown( 'visa_n_work_permits',
										$options = coBuyerOrSellerDataConfig(),
										$selected = array(),
										"id='visa_n_work_permits' class='width270'"
									);
		
		$available_for = "<table><tr>";
		$i = 0;
		foreach ( countryZoneDataConfig() as $key => $value ){
			if($i % 3 == 0 AND $i!= 0){
				$available_for .= "</tr><tr>";
			}
			$i++;
			$available_for .= "<td width='250px;'><input type='checkbox' name='available_for[]' id='available_for[]' value='$key' />&nbsp;$value </td>";
		}		
		$available_for .= "</tr></table>";
		
		$music_genre = "<table><tr>";
		$i = 0;
		foreach ( musicGenreDataConfig() as $key => $value ){
			if($i % 3 == 0 AND $i!= 0){
				$music_genre .= "</tr><tr>";
			}
			$i++;
			$music_genre .= "<td width='250px;'><input type='checkbox' name='music_genre[]' id='music_genre[]' value='$key' />&nbsp;$value </td>";
		}		
		$music_genre .= "</tr></table>";	
		
		$speaker_profile = "<table><tr>";
		$i = 0;
		foreach ( speakerProfileDataConfig() as $key => $value ){
			if($i % 3 == 0 AND $i!= 0){
				$speaker_profile .= "</tr><tr>";
			}
			$i++;
			$speaker_profile .= "<td width='250px;'><input type='checkbox' name='speaker_profile[]' id='speaker_profile[]' value='$key' />&nbsp;$value </td>";
		}
		$speaker_profile .= "</tr></table>";	
		
		$plays_musicals = "<table><tr>";
		$i = 0;
		foreach ( playsMusicalsDataConfig() as $key => $value ){
			if($i % 3 == 0 AND $i!= 0){
				$plays_musicals .= "</tr><tr>";
			}
			$i++;
			$plays_musicals .= "<td width='250px;'><input type='checkbox' name='plays_musicals[]' id='plays_musicals[]' value='$key' />&nbsp;$value </td>";
		}
		$plays_musicals .= "</tr></table>";	
		
		$bidOpen = "";
		foreach( bidOpenToDataConfig() as $key => $value){
			$bidOpen .= "<input type='checkbox' name='bid_open[]' id='__$key' value='$key' />&nbsp;$value&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		}
		
		return array(	'show_type'=>$showType,'show_duration'=>$durationShow, 
						'country_origin'=>$countryOrigin, 'available_for'=>$available_for,
						'air_travel'=>$air_travel, 'ground'=>$ground, 'hotel'=>$hotel,
						'per_diem'=>$per_diem, 'light_n_sound'=>$light_n_sound, 'rider_req'=>$rider_req,
						'visa_n_work_permits'=>$visa_n_work_permits, 'music_genre'=>$music_genre,
						'speaker_profile'=> $speaker_profile ,'plays_musicals'=>$plays_musicals,'bidOpen'=>$bidOpen
					);	

	}
	
	function save_show(){
		$USER = $this->user_entity->init('id', $_SESSION['user']['id']);
		$show_id = $this->show_entity->createNewShowEntity($_SESSION['show']['ref_no']);
		$SHOW = $this->show_entity->init('id',$show_id);
		$SHOW->setUserCreatedId($_SESSION['show']['user_created_id']);
		$SHOW->setName($_SESSION['show']['name']);
		$SHOW->setShowType($_SESSION['show']['show_type']);
		$SHOW->setShowDuration($_SESSION['show']['show_duration'] );
		$SHOW->setBidType($_SESSION['show']['bid_type'] );
		$SHOW->setArtist($_SESSION['show']['artist']);
		$SHOW->setCountryOriginCode($_SESSION['show']['country_origin_code']);
		$SHOW->setMusicGenre($_SESSION['show']['music_genre']);
		$SHOW->setSpeakerProfile($_SESSION['show']['speaker_profile']);
		$SHOW->setPlaysMusicals($_SESSION['show']['plays_musicals'] );
		$SHOW->setStartDate($_SESSION['show']['start_date']);
		$SHOW->setEndDate($_SESSION['show']['end_date']);
		$SHOW->setBidDueDate($_SESSION['show']['bid_due_date']);
		$SHOW->setAvailableFor($_SESSION['show']['available_for']);
		$SHOW->setEntourageNo($_SESSION['show']['entourage_no'] );
		$SHOW->setMinBid($_SESSION['show']['min_bid']);
		$SHOW->setAirTravel($_SESSION['show']['air_travel']);
		$SHOW->setGround($_SESSION['show']['ground']);
		$SHOW->setHotel($_SESSION['show']['hotel']);
		$SHOW->setPerDiem($_SESSION['show']['per_diem']);
		$SHOW->setLightAndSound($_SESSION['show']['light_n_sound']);
		$SHOW->setRiderReq($_SESSION['show']['rider_req']);
		$SHOW->setVisaAndWorkPermits($_SESSION['show']['visa_n_work_permits']);
		$SHOW->setAdditional($_SESSION['show']['additional']);
		$SHOW->setTechRider($_SESSION['show']['tech_rider']);
		$SHOW->setShowImage1($_SESSION['show']['show_image_1']);
		$SHOW->setShowImage2($_SESSION['show']['show_image_2']);
		$SHOW->setShowImage3($_SESSION['show']['show_image_3']);
		$SHOW->setHospitalityRider($_SESSION['show']['hospitality_rider']);
		$SHOW->setStatus('pending');
		$SHOW->setCreatedTime(time());
		
		$SHOW->update();
		
		//send an email to seller ...
		$this->crontab_email->cronUpdate(strval($USER->getAccCode()."SHOW-ADD".$SHOW->getRefNo()),'_sendEmailToUser_createNewShow', strval($USER->getId().','.$SHOW->getRefNo()), array(time()) );
		echo 'ok';exit();
	}
	
	function submit_show(){
		$USER = $this->user_entity->init('id', $_SESSION['user']['id']);
		cleanFilesNotUsed($USER->getId());
		
		$_SESSION['show'] = array();
		
		$error_array = array();
		
		$start_date = convertToTimeStampFromFormat($format = "d-F-Y", $str=$this->input->post('start_date',''));
		$end_date = convertToTimeStampFromFormat($format = "d-F-Y", $str=$this->input->post('end_date',''));
		$bid_due_date = convertToTimeStampFromFormat($format = "d-F-Y", $str=$this->input->post('bid_due_date',''));
		
		if(empty($_POST['show_name'])){
			$error_array[] = 'show_name';
		}
		
		if(empty($_POST['artist'])){
			$error_array[] = 'artist';
		}
		
		if(empty($_POST['bid_open'])){
			$error_array[] = 'bid_open';
		}
		
	//	if(empty($_POST['music_genre'])){
	//		$error_array[] = 'music_genre';
	//	}
		
	//	if(empty($_POST['speaker_profile'])){
	//		$error_array[] = 'speaker_profile';
	//	}
		
	//	if(empty($_POST['plays_musicals'])){
	//		$error_array[] = 'plays_musicals';
	//	}
		
		if($start_date == 0 || $end_date == 0 || $bid_due_date == 0 || $start_date>$end_date || $end_date < time() ){
			$error_array[] = 'period';
		}  
		
		if( $bid_due_date > $start_date || $bid_due_date < time() ){
			$error_array[] = 'bid_due_date';
		}
		
		if(empty($_POST['available_for'])){
			$error_array[] = 'available_for';
		}
		
		if(!is_integer(intval($_POST['entourage_no'])) || $_POST['entourage_no'] <= 0){
			$error_array[] = 'entourage_no';
		}
		
		if(!is_numeric($_POST['min_bid']) || $_POST['min_bid'] <= 0){
			$error_array[] = 'min_bid';
		}
		
	//	if(empty($_POST['additional'])){
	//		$error_array[] = 'additional';
	//	}
		
		$tech_rider = $show_image_1 = $show_image_2 = $show_image_3 = $hospitality_rider = "";
		
		if(($_FILES["tech_rider"]['size']/1000000) > allowMaxFileSize() ){
			$tech_rider = '';
		}else{
			$tech_rider = $this->module_helper->uploadFile( 
									$_FILES["tech_rider"]['tmp_name'],
									$_FILES["tech_rider"]['name'],
									$USER->getFolderFileStorage(),
									allowExtensionFileDocumentUpload()
								);
		}	
		
		if(($_FILES["show_image_1"]['size']/1000000) > allowMaxFileSize() ){
			$show_image_1 = '';
		}else{
			$show_image_1 = $this->module_helper->uploadFile( 
									$_FILES["show_image_1"]['tmp_name'],
									$_FILES["show_image_1"]['name'],
									$USER->getFolderFileStorage(),
									allowExtensionPictureUpload()
								);
		}	
		
		if(($_FILES["show_image_2"]['size']/1000000) > allowMaxFileSize() ){
			$show_image_2 = '';
		}else{
			$show_image_2 = $this->module_helper->uploadFile( 
									$_FILES["show_image_2"]['tmp_name'],
									$_FILES["show_image_2"]['name'],
									$USER->getFolderFileStorage(),
									allowExtensionPictureUpload()
								);
		}
		
		if(($_FILES["show_image_3"]['size']/1000000) > allowMaxFileSize() ){
			$show_image_3 = '';
		}else{
			$show_image_3 = $this->module_helper->uploadFile( 
									$_FILES["show_image_3"]['tmp_name'],
									$_FILES["show_image_3"]['name'],
									$USER->getFolderFileStorage(),
									allowExtensionPictureUpload()
								);
		}
		
		if(($_FILES["hospitality_rider"]['size']/1000000) > allowMaxFileSize() ){
			$hospitality_rider = '';
		}else{
			$hospitality_rider = $this->module_helper->uploadFile( 
									$_FILES["hospitality_rider"]['tmp_name'],
									$_FILES["hospitality_rider"]['name'],
									$USER->getFolderFileStorage(),
									allowExtensionFileDocumentUpload()
								);
		}	
		
		if(empty($tech_rider)){
			$error_array[] = 'tech_rider';
		}	
		if(empty($show_image_1) AND empty($show_image_2) AND empty($show_image_3)){
			$error_array[] = 'show_image';
		}
		if($_FILES["hospitality_rider"]['tmp_name'] AND empty($hospitality_rider)){
			$error_array[] = 'hospitality_rider';
		}
		
		if(!empty($error_array)){
			echo "err#".implode("#",$error_array);
			exit();
		}else{
			$array_init = array('speaker_profile', 'plays_musicals', 'music_genre', 'bid_open', 'available_for');
			foreach($array_init as $element){
				if(!isset($_POST[$element])){
					$_POST[$element] = array();
				}
			}
			
		/**	$show_id = $this->show_entity->createNewShowEntity($this->digit->generateDitgit4Show());
		
			$SHOW = $this->show_entity->init('id',$show_id);
			
			$SHOW->setUserCreatedId($USER->getId());
			$SHOW->setName($this->input->post('show_name',''));
			$SHOW->setShowType($this->input->post('show_type',''));
			$SHOW->setShowDuration($this->input->post('show_duration',''));
			$SHOW->setBidType(implode(',', $_POST['bid_open']));
			$SHOW->setArtist($this->input->post('artist',''));
			$SHOW->setCountryOriginCode($this->input->post('country_origin',''));
			$SHOW->setMusicGenre(implode(',', $_POST['music_genre']));
			$SHOW->setSpeakerProfile(implode(',', $_POST['speaker_profile']));
			$SHOW->setPlaysMusicals(implode(',', $_POST['plays_musicals']));
			$SHOW->setStartDate($start_date);
			$SHOW->setEndDate($end_date);
			$SHOW->setBidDueDate($bid_due_date);
			$SHOW->setAvailableFor(implode(',',$_POST['available_for']));
			$SHOW->setEntourageNo(intval($_POST['entourage_no']));
			$SHOW->setMinBid($_POST['min_bid']);
			$SHOW->setAirTravel($this->input->post('air_travel',''));
			$SHOW->setGround($this->input->post('ground',''));
			$SHOW->setHotel($this->input->post('hotel',''));
			$SHOW->setPerDiem($this->input->post('per_diem',''));
			$SHOW->setLightAndSound($this->input->post('light_n_sound',''));
			$SHOW->setRiderReq($this->input->post('rider_req',''));
			$SHOW->setVisaAndWorkPermits($this->input->post('visa_n_work_permits',''));
			$SHOW->setAdditional($this->input->post('additional',''));
			$SHOW->setTechRider($tech_rider);
			$SHOW->setShowImage1($show_image_1);
			$SHOW->setShowImage2($show_image_2);
			$SHOW->setShowImage3($show_image_3);
			$SHOW->setHospitalityRider($hospitality_rider);
			$SHOW->setStatus('pending');
			$SHOW->setCreatedTime(time());
			
			$SHOW->update();
			
			//send an email to seller ...
			$this->crontab_email->cronUpdate(strval($USER->getAccCode()."SHOW-ADD".$SHOW->getRefNo()),'_sendEmailToUser_createNewShow', strval($USER->getId().','.$SHOW->getRefNo()), array(time()) );
		**/
			$_SESSION['show']['ref_no'] = $this->digit->generateDitgit4Show();
			$_SESSION['show']['user_created_id'] = $USER->getId();
			$_SESSION['show']['name'] = $this->input->post('show_name','');
			$_SESSION['show']['show_type'] = $this->input->post('show_type','');
			$_SESSION['show']['bid_type'] = implode(',', $_POST['bid_open']);
			$_SESSION['show']['show_duration'] = $this->input->post('show_duration','');
			$_SESSION['show']['artist'] = $this->input->post('artist','');
			$_SESSION['show']['country_origin_code'] = $this->input->post('country_origin','');
			$_SESSION['show']['music_genre'] = implode(',', $_POST['music_genre']);
			$_SESSION['show']['speaker_profile'] = implode(',', $_POST['speaker_profile']);
			$_SESSION['show']['plays_musicals'] = implode(',', $_POST['plays_musicals']);
			$_SESSION['show']['start_date'] = $start_date;
			$_SESSION['show']['end_date'] = $end_date;
			$_SESSION['show']['bid_due_date'] = $bid_due_date;
			$_SESSION['show']['available_for'] = implode(',',$_POST['available_for']);
			$_SESSION['show']['entourage_no'] = intval($_POST['entourage_no']);
			$_SESSION['show']['min_bid'] = $_POST['min_bid'];
			$_SESSION['show']['air_travel'] = $this->input->post('air_travel','');
			$_SESSION['show']['ground'] = $this->input->post('ground','');
			$_SESSION['show']['hotel'] = $this->input->post('hotel','');
			$_SESSION['show']['per_diem'] = $this->input->post('per_diem','');
			$_SESSION['show']['light_n_sound'] = $this->input->post('light_n_sound','');
			$_SESSION['show']['rider_req'] = $this->input->post('rider_req','');
			$_SESSION['show']['visa_n_work_permits'] = $this->input->post('visa_n_work_permits','');
			$_SESSION['show']['additional'] = $this->input->post('additional','');
			$_SESSION['show']['tech_rider'] = $tech_rider;
			$_SESSION['show']['show_image_1'] = $show_image_1;
			$_SESSION['show']['show_image_2'] = $show_image_2;
			$_SESSION['show']['show_image_3'] = $show_image_3;
			$_SESSION['show']['hospitality_rider'] = $hospitality_rider;
			
			//echo 'ok#'.site_url('seller/add_show/add_notify');
			echo 'ok#'.site_url('seller/add_show/preview_show');
			exit();
		}		
	}
	
	function cancel_and_create(){
		$USER = $this->user_entity->init('id', $_SESSION['user']['id']);
		$SHOW = $this->show_entity->init('id', intval($this->input->get('show_id',''))) or show_404();
		
		if( $SHOW->getUserCreatedId() != $USER->getId() ){
			show_404();exit();
		}
		
		$SHOW->setStatus('cancelled');
		$SHOW->update();
		
		//send an email to seller ...
		//$this->crontab_email->cronUpdate(strval($USER->getAccCode()."cancel_and_create".$SHOW->getRefNo()),'_sendEmailToUser_cancelledAndCreateNewShow', strval($USER->getId().','.$SHOW->getRefNo()), strval(time()) );
		//$this->crontab_email->cronExec( strval($USER->getAccCode()."cancel_and_create".$SHOW->getRefNo()) );
		redirect(site_url('seller/add_show'));
	}
	
	function edit_show(){
		$USER = $this->user_entity->init('id', $_SESSION['user']['id']);
		$SHOW = $this->show_entity->init('id', $this->input->post('show_id',''));
		
		if( $SHOW->getUserCreatedId() != $USER->getId() ){
			show_404();exit();
		}
		
		cleanFilesNotUsed($USER->getId());
		
		$error_array = array();
		
		$start_date = convertToTimeStampFromFormat($format = "d-F-Y", $str=$this->input->post('start_date',''));
		$end_date = convertToTimeStampFromFormat($format = "d-F-Y", $str=$this->input->post('end_date',''));
		$bid_due_date = convertToTimeStampFromFormat($format = "d-F-Y", $str=$this->input->post('bid_due_date',''));
		
		if(empty($_POST['show_name'])){
			$error_array[] = 'show_name';
		}
		
		if(empty($_POST['artist'])){
			$error_array[] = 'artist';
		}
		
		if(empty($_POST['bid_open'])){
			$error_array[] = 'bid_open';
		}
		
	///	if(empty($_POST['music_genre'])){
	//		$error_array[] = 'music_genre';
	//	}
		
	//	if(empty($_POST['speaker_profile'])){
	//		$error_array[] = 'speaker_profile';
	//	}
		
	//	if(empty($_POST['plays_musicals'])){
	//		$error_array[] = 'plays_musicals';
	//	}
		
		if($start_date == 0 || $end_date == 0 || $bid_due_date == 0 || $start_date>$end_date || $end_date < time() ){
			$error_array[] = 'period';
		}  
		
		if( $bid_due_date > $start_date || $bid_due_date < time() ){
			$error_array[] = 'bid_due_date';
		}
		
		if(empty($_POST['available_for'])){
			$error_array[] = 'available_for';
		}
		
		if(!is_integer(intval($_POST['entourage_no'])) || $_POST['entourage_no'] <= 0){
			$error_array[] = 'entourage_no';
		}
		
		if(!is_numeric($_POST['min_bid']) || $_POST['min_bid'] <= 0){
			$error_array[] = 'min_bid';
		}
		
		if(empty($_POST['additional'])){
			$error_array[] = 'additional';
		}
		
		$tech_rider = $SHOW->getTechRider();
		$show_image_1 = $SHOW->getShowImage1();
		$show_image_2 = $SHOW->getShowImage2();
		$show_image_3 = $SHOW->getShowImage3();
		$hospitality_rider = $SHOW->getHospitalityRider();
		
		if(isset($_FILES["tech_rider"]) AND !empty($_FILES["tech_rider"]['name'])) {
			if(($_FILES["tech_rider"]['size']/1000000) > allowMaxFileSize() ){
				$tech_rider = '';
			}else{
				$tech_rider = $this->module_helper->uploadFile( 
										$_FILES["tech_rider"]['tmp_name'],
										$_FILES["tech_rider"]['name'],
										$USER->getFolderFileStorage(),
										allowExtensionFileDocumentUpload()
									);
			}	
		}
		
		if(isset($_FILES["show_image_1"]) AND !empty($_FILES["show_image_1"]['name'])) {
			if(($_FILES["show_image_1"]['size']/1000000) > allowMaxFileSize() ){
				$show_image_1 = '';
			}else{
				$show_image_1 = $this->module_helper->uploadFile( 
										$_FILES["show_image_1"]['tmp_name'],
										$_FILES["show_image_1"]['name'],
										$USER->getFolderFileStorage(),
										allowExtensionPictureUpload()
									);
			}	
		}
		
		if(isset($_FILES["show_image_2"]) AND !empty($_FILES["show_image_2"]['name'])) {
			if(($_FILES["show_image_2"]['size']/1000000) > allowMaxFileSize() ){
				$show_image_2 = '';
			}else{
				$show_image_2 = $this->module_helper->uploadFile( 
										$_FILES["show_image_2"]['tmp_name'],
										$_FILES["show_image_2"]['name'],
										$USER->getFolderFileStorage(),
										allowExtensionPictureUpload()
									);
			}
		}
		
		if(isset($_FILES["show_image_3"]) AND !empty($_FILES["show_image_3"]['name'])) {
			if(($_FILES["show_image_3"]['size']/1000000) > allowMaxFileSize() ){
				$show_image_3 = '';
			}else{
				$show_image_3 = $this->module_helper->uploadFile( 
										$_FILES["show_image_3"]['tmp_name'],
										$_FILES["show_image_3"]['name'],
										$USER->getFolderFileStorage(),
										allowExtensionPictureUpload()
									);
			}
		}
		
		if(isset($_FILES["hospitality_rider"]) AND !empty($_FILES["hospitality_rider"]['name'])) {
			if(($_FILES["hospitality_rider"]['size']/1000000) > allowMaxFileSize() ){
				$hospitality_rider = '';
			}else{
				$hospitality_rider = $this->module_helper->uploadFile( 
										$_FILES["hospitality_rider"]['tmp_name'],
										$_FILES["hospitality_rider"]['name'],
										$USER->getFolderFileStorage(),
										allowExtensionFileDocumentUpload()
									);
			}	
		}
		
		if(empty($tech_rider)){
			$error_array[] = 'tech_rider';
		}	
		if(empty($show_image_1) AND empty($show_image_2) AND empty($show_image_3)){
			$error_array[] = 'show_image';
		}
		if(!empty($_FILES["hospitality_rider"]['tmp_name']) AND empty($hospitality_rider)){
			$error_array[] = 'hospitality_rider';
		}
		
		if(!empty($error_array)){
			echo "err#".implode("#",$error_array);
			exit();
		}else{
			$array_init = array('speaker_profile', 'plays_musicals', 'music_genre', 'bid_open', 'available_for');
			foreach($array_init as $element){
				if(!isset($_POST[$element])){
					$_POST[$element] = array();
				}
			}
			
			$revision = $SHOW->buildNewRevision();
			
			$SHOW->setUserCreatedId($USER->getId());
			$SHOW->setName($this->input->post('show_name',''));
			$SHOW->setShowType($this->input->post('show_type',''));
			$SHOW->setShowDuration($this->input->post('show_duration',''));
			$SHOW->setBidType(implode(',', $_POST['bid_open']));
			$SHOW->setArtist($this->input->post('artist',''));
			$SHOW->setCountryOriginCode($this->input->post('country_origin',''));
			$SHOW->setMusicGenre(implode(',', $_POST['music_genre']));
			$SHOW->setSpeakerProfile(implode(',', $_POST['speaker_profile']));
			$SHOW->setPlaysMusicals(implode(',', $_POST['plays_musicals']));
			$SHOW->setStartDate($start_date);
			$SHOW->setEndDate($end_date);
			$SHOW->setBidDueDate($bid_due_date);
			$SHOW->setAvailableFor(implode(',',$_POST['available_for']));
			$SHOW->setEntourageNo(intval($_POST['entourage_no']));
			$SHOW->setMinBid($_POST['min_bid']);
			$SHOW->setAirTravel($this->input->post('air_travel',''));
			$SHOW->setGround($this->input->post('ground',''));
			$SHOW->setHotel($this->input->post('hotel',''));
			$SHOW->setPerDiem($this->input->post('per_diem',''));
			$SHOW->setLightAndSound($this->input->post('light_n_sound',''));
			$SHOW->setRiderReq($this->input->post('rider_req',''));
			$SHOW->setVisaAndWorkPermits($this->input->post('visa_n_work_permits',''));
			$SHOW->setAdditional($this->input->post('additional',''));
			$SHOW->setTechRider($tech_rider);
			$SHOW->setShowImage1($show_image_1);
			$SHOW->setShowImage2($show_image_2);
			$SHOW->setShowImage3($show_image_3);
			$SHOW->setHospitalityRider($hospitality_rider);
			//$SHOW->setStatus('opening');
			$SHOW->setCreatedTime(time());
			
			$SHOW->setRevision($revision);
			$SHOW->update();
			
			//send an email to seller ...
			//send an email to seller ...
			$this->crontab_email->cronUpdate(strval($USER->getAccCode()."SHOW-EDIT".$SHOW->getRefNo()),'_sendEmailToUser_editShow', strval($USER->getId().','.$SHOW->getRefNo()), array(time()) );
		
			echo 'ok#'.site_url('seller/show_manage/edit_show_notify/?show_id='.$SHOW->getId());
			exit();
		}	
	}
	
	
	
	
	
}